package com.zero.system.service.Impl;

import com.zero.system.entity.Customer;
import com.zero.system.mapper.CustomerMapper;
import com.zero.system.service.CustomerService;
import com.zero.system.util.PageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerMapper customerMapper;

    @Override
    public PageBean<Customer> queryPage(Map<String, Object> paramMap) {
        PageBean<Customer> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));
        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Customer> datas = customerMapper.queryList(paramMap);
        pageBean.setDatas(datas);
        Integer totalsize = customerMapper.getCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public Integer getCount(Map<String, Object> paramMap) {
        return customerMapper.getCount(paramMap);
    }

    @Override
    public int add(Customer models) {
        return customerMapper.add(models);
    }

    @Override
    public Customer findById(Integer id) {
        return customerMapper.findById(id);
    }

    @Override
    public int delete(List<Integer> ids) {
        return customerMapper.delete(ids);
    }

    @Override
    public int update(Customer models) {
        return customerMapper.update(models);
    }

    @Override
    public Customer findByUserName(String username) {
        return customerMapper.findByUserName(username);
    }

    @Override
    public List<Customer> findAll() {
        return customerMapper.findAll();
    }

    @Override
    public Customer login(String username, String password) {
        return customerMapper.login(username,password);
    }
}
